<%@ page language="java" pageEncoding="UTF-8" %>
<% 
    String context = request.getContextPath();
    request.setAttribute("context",context);
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>用户</title>
    <link href="${context}/static/jquery-easyui-1.3.2/themes/gray/easyui.css" rel="stylesheet" type="text/css" />
    <link href="${context}/static/jquery-easyui-1.3.2/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="${context}/static/jquery-easyui-1.3.2/jquery-1.8.0.min.js" type="text/javascript"></script>
    <script src="${context}/static/jquery-easyui-1.3.2/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="${context}/static/jquery-easyui-1.3.2/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
    <script src="${context}/static/scripts/json2.js" type="text/javascript"></script>
    <script src="${context}/static/scripts/common.js" type="text/javascript"></script> 
    <style type="text/css">
        body {
            padding: 0px;
            margin: 0px;
        }
    </style>
    <script type="text/javascript">
    
    		var currentNode=null;
    
			var easyuiTreeData=[{
			        "text":"生成表格行头",
			        "checked":true,
			        "attributes":{
			        	"url":"${context}/db/columns.html",
			        	"p":["t"]			        	
        			}
			    },{
			        "text":"根据表名生成javabean",
			        "checked":true,
			        "attributes":{
			        	"url":"${context}/db/javaBean.html",
			        	"p":["t"]			        
        			}
			    },{
			        "text":"JDBC 查询",
			        "checked":true,
			        "attributes":{
			        	"url":"${context}/db/jdbcquery.html",
			        	"p":["t","b"]
        			}
			    },{
			        "text":"JDBC 插入",
			        "checked":true,
			        "attributes":{
			        	"url":"${context}/db/jdbcinsert.html",
			        	"p":["t"]			        
        			}
			    },{
			        "text":"toString",
			        "checked":true,
			        "attributes":{
			        	"url":"${context}/db/toString.html",
			        	"p":["t"]			        
        			}
			    }
			    ];    
			    
		function generate() {
			if(!currentNode) alert("请在左侧选择");
			var node=currentNode;
	       	if(node.attributes && node.attributes.url) {
	       		var url=node.attributes.url;
	       		var p=node.attributes.p;
	       		if(p) {
	       			for(var i=0;i<p.length;i++) {
	       				var id="#"+p[i];
	       				var vv=$(id).val()
	       				var parmeter=p[i]+"="+vv;
	       				if(i==0) {
	       					url=url+"?"+parmeter;
	       				}else {
	       					url=url+"&"+parmeter;
	       				}
	       			}
	       		}
	       	}	
	       	window.open(url);
		}	    
			    
			    
    
        $(document).ready(function () {
	            $("#Explorer").accordion({
	                fit: true,
	                animate: false,
	                onSelect: function(title) {
	                }
	            });  
			    $("#easyuiTree").tree({
			        checkbox: false,
			        dnd: false,
			        onClick: function (node) {
						currentNode=node;
			        }, 
			        onContextMenu: function (e, row) {
			        }, 
			        onLoadSuccess: function (note, data) {          	
			        }, 
			        onDrop: function (e, source) {
			        }
			    });
			   
			    $("#easyuiTree").tree("loadData", easyuiTreeData);
			    
			    
        });
        	   
    </script>
</head>
<body>
    <div class="easyui-layout" style="width: 100%; height: 100%;">
        <div region="west" split="true" title="代码生成" style="width: 220px; overflow: auto; padding-top: 0px;">
            <div id="Explorer" class="easyui-accordion" border="false">
                <div title="DSF代码生成" iconcls="icon-edit" style="overflow: auto; padding: 10px;">
                	<ul id="easyuiTree"></ul>
                </div>
            </div>
        </div>
        <div region="center" border="false" style="overflow: hidden;">
        
			<form id="opinionsForm">
				<table style="font-size:12px;">
					<tr>
						<td class="colTitle">表名：</td>
						<td class="colValue"><input id="t" type="text" value="" style="width:200px" maxlength="100" /></td>
					</tr>
					<tr>
						<td class="colTitle">实体：</td>
						<td class="colValue"><input id="b" type="text" value="" style="width:200px" maxlength="100" /></td>
					</tr>	
				</table>
			</form>	        
        	<a href="#" onclick="generate();return false;">生成代码</a>
        </div>
    </div>
</body>
</html>
